#include <QtGui/QApplication>
#include <QLabel>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QMenu>
#include <QMenuBar>
#include <QtSql>
#include "mainwindow.h"
#include <iostream>
#include <QHttp>

int main(int argc, char *argv[])
{

    QApplication app(argc, argv);
    QSqlDatabase dbase = QSqlDatabase::addDatabase("QSQLITE");
    dbase.setDatabaseName("downloadmanager.sqlite");



    if(!dbase.open()){
        std::cerr << "Db opening failure";
        return 1;
    }

    MainWindow window (0,&dbase);
    window.setWindowTitle("DownloadManager");

    QMenuBar *menuBar = window.menuBar();
    QMenu menu("Menu");

    menu.addAction("New download",
                    &window,
                    SLOT(addDownload()),
                    Qt::CTRL + Qt::Key_N);

    menu.addAction("Remove download",
                    &window,
                    SLOT(removeDownload()),
                    Qt::Key_Backspace);

    menu.addAction("Exit",
                    &app,
                    SLOT(quit()),
                    Qt::CTRL + Qt::Key_Q);

    menuBar->addMenu(&menu);
    window.show();
    return app.exec();
}
